<?php
namespace app\index\service;


use app\index\model\EnginChanModel;
use app\index\model\EnginDiaryModel;
use app\index\model\EnginSpeedModel;
use app\index\model\SpeedMonthModel;

class SceneService extends CommonService
{
    public function check_engin_chan_month($month, $enginid, $id=0){
        return !!EnginChanModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'month'=>$month,'deleted_user'=>0])
            ->where(['isturn'=>1])->where('status','in',[0,1])->where('id','neq', $id)->find();
    }
    public function check_speed_month_name($name, $month, $enginid, $id=0){
        return !!SpeedMonthModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'month'=>$month,'name'=>$name,'deleted_user'=>0])
            ->where('id','neq', $id)->find();
    }
    public function check_engin_speed_month($month, $enginid, $id=0){
        return !!EnginSpeedModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'month'=>$month,'deleted_user'=>0])
            ->where(['isturn'=>1])->where('status','in',[0,1])->where('id','neq', $id)->find();
    }
    public function check_engin_diary_dt($dt, $enginid, $id=0){
        return !!EnginDiaryModel::where(['comid'=>$this->userinfo['comid'],'enginid'=>$enginid,'dt'=>$dt,'deleted_user'=>0])
            ->where(['isturn'=>1])->where('status','in',[0,1])->where('id','neq', $id)->find();
    }


    public function get_engin_xun_level(){
        return [
            '一般问题',
            '严重问题',
            '重大问题',
        ];
    }
    public function get_zheng_gaista(){
        return [
            0 => '待整改',
            1 => '已整改',
        ];
    }
    public function get_zheng_gaista_name($gaista, $dt){
        $arr = $this->get_zheng_gaista();
        $str = isset($arr[$gaista]) ? $arr[$gaista] : '';
        if($gaista == 0){
            if($dt < date("Y-m-d")){
                $str = '<span class="colorhong">逾期未整改</span>';
            }
        }
        return $str;
    }


    public function get_zheng_fusta(){
        return [
            1 => '待复检',
            2 => '复检通过',
            3 => '复检不通过',
        ];
    }
    public function get_zheng_fusta_name($fusta){
        $arr = $this->get_zheng_fusta();
        $str = isset($arr[$fusta]) ? $arr[$fusta] : '';
        return $str;
    }





























































}
